<template>
	<view class="content">
		<navbar title='我的团队'>
		</navbar>
		<view class="content">
			<u-sticky offset-top="0">
				<view class="tuanone">
					<scroll-view class="tuhead" scroll-x>
						<view class="tuitem " :class="typeitem.id==item.id?'tactive':''" v-for="(item,index) in typelist" :key="index" @click="gethead(item)">
							{{item.name+ '('+item.nums+')'}}
						</view>
					</scroll-view>
					<image class="icon_tx" @click="getyueji" src="@/pages_client/static/img/icon_tx.png" />
				</view>
			</u-sticky>
			<view class="nlist">
				<view class="nitem" v-for="(item,index) in list" :key="index">
					<view class="nione">
						<image class="tous" :src="item.avatar?item.avatar:'@/pages_client/static/img/LOGO.png'" />
						<view class="niright">
							<view class="rione">
								<text class="riname txt">{{ item.nickname }}</text>
								<text class="hyuan">{{item.group_name}}</text>
							</view>
							<view class="rione mttwo">
								<text class="idname txt">ID:{{item.id}}</text>
								<text class="idname hui">注册时间：{{item.createtime}}</text>
							</view>
						</view>
						<image class="comm_icon_next" src="@/pages_client/static/img/comm_icon_next.png" />
					</view>
					<view class="zheview">
						<view class="zheitem">
							<view class="items" v-if="item.zhitui_nums">
								<text class="ileft">直推下线人数:</text>
								<text class="ival">{{ item.zhitui_nums }}</text>
							</view>
							<view class="items" v-if="item.zhigou_order_money">
								<text class="ileft">直购订单金额:</text>
								<text class="ival">{{item.zhigou_order_money}}元</text>
							</view>
							<view class="items" v-if="item.zhitui_order_nums">
								<text class="ileft">直推下级订单数据:</text>
								<text class="ival">{{ item.zhitui_order_nums }}</text>
							</view>
							<view class="items" v-if="item.zhitui_order_money">
								<text class="ileft">直推下线订单金额:</text>
								<text class="ival">{{item.zhitui_order_money}}元</text>
							</view>
							<view class="items" v-if="item.zhitui_id">
								<text class="ileft">上线ID:</text>
								<text class="ival">{{ item.zhitui_id }}</text>
							</view>
						</view>
						<view class="shengbtn">
							<view class="sbtn">升级权限</view>
						</view>
					</view>
				</view>
				<u-loadmore :status="status" @loadmore="loadmore" />
			</view>
		</view>

		<view class="botview">
			<view class="tjia" @click="getadd">添加团队人员</view>
		</view>

		<!-- 添加团队成员 -->
		<AddTeamPop :teampopshow="teampopshow" @closeteam="closeteam" @getxuanmen="getxuanmen"></AddTeamPop>
	</view>
</template>

<script>
import AddTeamPop from '@/pages_client/components/AddTeamPop/AddTeamPop'
	export default {
		components: {
			AddTeamPop
		},
		data() {
			return {
				teampopshow:false,
				typelist:[],
				typeitem:{},
				list: [],
				page: 1,
				limit: 10,
				last_page: 1,
				status: "loadmore",
				
			}
		},
		onLoad() {
			this.getClass();//分类
		},
		onShow() {
		},
		methods: {
			async getClass(){
				let res = await this.$u.api.getMyTeamType({
				});
				if(res){
					this.typelist = res
					this.typeitem = res[0]
					this.getClear()
				}
				
			},
			closeteam(){
				this.teampopshow = false
			},
			getyueji(){
				this.navrouter("/pages_client/twoPage/MyTeamYueji");
			},
			async getList(){//列表数据
				let res = await this.$u.api.getMyTeam({
					type:this.typeitem.id,
				  	page:this.page
				});
				this.last_page = res.lastpage
				let list = res.list;
				this.list = this.page == 1 ? list : [...this.list, ...list];	
				if(res.list==''||Number(list.length)<Number(this.limit)||Number(this.page)>Number(this.last_page)){
					this.status = 'nomore';
				}
				},
			loadmore() {
				let page = this.page;
				// let last_page = this.last_page;
				if (this.status == 'loadmore') {
					this.page++;
					this.getList();
				}
			},
			getClear(){
				this.list = []
				this.page = 1,
				this.status= "loadmore"
				this.getList()
			},
			getadd(){
				this.teampopshow = true
			},
			gethead(item){
				this.typeitem = item
				this.getClear()
			},
			getxuanmen(){
				this.teampopshow = false
				this.getClear()
			}
				
		},

	}
</script>

<style lang="scss" scoped>
	page{
		background-color: #f9f9f9;
	}
	.content{
		background-color: #f9f9f9;
		padding-bottom: 130rpx;
		min-height: 100vh;
		.tuanone{
			background-color: #fff;
			padding: 15rpx 30rpx;
			display: flex;
			flex-direction: row;
			align-items: center;
			.tuhead{
				max-width: 80%;
				white-space: nowrap;
				.tuitem{
					padding: 8rpx 20rpx;
					background: #F5F5F5;
					border-radius: 10rpx;
					margin-right: 20rpx;
					font-weight: 500;
					font-size: 26rpx;
					color: #333333;
					display: inline-block;
				}
				.tactive{
					background: #52443B;
					color: #fff;
				}
			}
			.icon_tx{
				margin-left: auto;
				width: 40rpx;
				height: 40rpx;
			}
		}	
	}
	.nlist{
		padding: 20rpx;
		display: flex;
		flex-direction: column;
		.nitem{
			padding: 20rpx 25rpx;
			background: #FFFFFF;
			border-radius: 30rpx;
			margin-bottom: 20rpx;
			.nione{
				display: flex;
				flex-direction: row;
				align-items: center;
				.tous{
					width: 81rpx;
					border-radius: 50%;
					height: 81rpx;
					margin-right: 15rpx;
				}
				.niright{
					width: 82%;
					display: flex;
					flex-direction: column;
					.rione{
						display: flex;
						flex-direction: row;
						align-items: center;
						.riname{
							max-width: 80%;
							display: inline-block;
							font-weight: bold;
							font-size: 32rpx;
							color: #333333;
						}
						.hyuan{
							// width: 80rpx;
							// height: 32rpx;
							padding: 4rpx 20rpx;
							background: linear-gradient(-90deg, #272727, #4D4D4D);
							border-radius: 6rpx;
							display: flex;
							align-items: center;
							justify-content: center;
							font-weight: 500;
							font-size: 22rpx;
							color: #FFFFFF;
							margin-left: 10rpx;
						}
						.idname{
							font-weight: 400;
							font-size: 24rpx;
							color: #999999;
						}
						.hui{
							margin-left: 40rpx;
						}

					}
					.mttwo{
						margin-top: 15rpx;
					}
				}
				.comm_icon_next{
					margin-left: auto;
					width: 24rpx;
					height: 24rpx;
				}
			}
			.zheview{
				border-top: 1rpx solid #eee;
				display: flex;
				flex-direction: column;
				margin-top: 20rpx;
				padding-top: 20rpx;
				.zheitem{
					display: flex;
					flex-direction: row;
					flex-wrap: wrap;
					.items{
						width: 50%;
						display: flex;
						flex-direction: row;
						align-items: center;
						margin-bottom: 10rpx;
						.ileft{
							font-weight: 500;
							font-size: 24rpx;
							color: #999999;
						}
						.ival{
							font-weight: 500;
							font-size: 26rpx;
							color: #333333;
						}
					}
				}
				.shengbtn{
					display: flex;
					flex-direction: row;
					justify-content: flex-end;
					padding: 0 20rpx 20rpx 0;
					.sbtn{
						padding: 15rpx 25rpx;
						background: #52443B;
						border-radius: 16rpx 16rpx 16rpx 16rpx;
						font-weight: bold;
						font-size: 28rpx;
						color: #FFFFFF;
						margin-left: 20rpx;
					}
				}
			}
		}
	}
	.botview{
		position: fixed;
		height: 120rpx;
		width: 100%;
		bottom: 0;
		background-color: #fff;
		z-index: 10;
		padding: 0 30rpx;
		display: flex;
		align-items: center;
		.tjia{
			width: 100%;
			height: 90rpx;
			background: #52443B;
			border-radius: 16rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			font-weight: bold;
			font-size: 28rpx;
			color: #FFFFFF;
		}
	}
</style>
